﻿
/*
*  文件名（File Name）：             TemplateViewModelCmd.cs
*  
*  作者（Author）：                  Haotian Zhou 周昊天 
* 
*  日期（Create Date）：             由 GIT 托管
* 
*  功能描述（Assisttion Description）：1、 无。
* 
*  修改记录（Revision Histroy）：    无
* 
*  备注（Remarks）：                 无
* 
*/

using Autodesk.Revit.DB;
using Autodesk.Revit.UI;

using Prism.Commands;
using Prism.Mvvm;
using Revit.Async;

using SEPD.CommonHelper;
using SEPD.Revit.Extension;

using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using System.Windows.Input;

namespace SEPD.Template.Revit1
{
    public partial class TemplateViewModel : BindableBase
    {
        private UIApplication application { get; set; }
        private Document document { get; set; }

        async void PreProccess()
        {
            //try
            //{ 
            //}
            //catch (Exception exp)
            //{ ExceptionProcess.InfoProcess(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType, exp.ToString()); }
            ////same as
            CommonVoidDelegate voidDelegate = new CommonVoidDelegate(() =>
            {
                //TODO: do-something PreProccess
                TaskDialog.Show("TIPS", "VM-STARTING");
            });
            CommonVoidExecutor(voidDelegate);


#if DEBUG

            Action<UIApplication> actionX = new Action<UIApplication>(
               app =>
               {
                   this.application = app;
                   this.document = app.ActiveUIDocument.Document;
               }
               );
            executeEventHandler.DelayRunAction(actionX); 

#else
            await RevitTask.RunAsync(app =>
            {
                try
                {
                    this.application = app;
                    this.document = app.ActiveUIDocument.Document;
                }
                catch (Exception exp)
                {
                    ExceptionProcess.InfoProcess(MethodBase.GetCurrentMethod().DeclaringType, exp.ToString());
                }
            });
#endif


            Thread.Sleep(20);
        }

        void TempExecute()
        {
            ///接入Revit操作   涉及revit工程操作
            ExecuteDelegate executeDelegate = new ExecuteDelegate(TempFunc);
#if DEBUG
            CommonSyncExecutor(executeDelegate, executeEventHandler);
#else 
            RevitAsyncExecutor(executeDelegate);
#endif  
        }


        void TempExecute2()
        {
            //普通操作  不涉及revit工程操作
            CommonVoidDelegate voidDelegate = new CommonVoidDelegate(() =>
            {
                //TODO: do-something execute
            });
            CommonVoidExecutor(voidDelegate);
        }


    }
}
